package com.haidechizi.doublecache.process;


import com.haidechizi.doublecache.annotation.DoubleCache;
import com.haidechizi.doublecache.enums.CacheType;

public class PutProcessService extends BaseProcessService {

    @Override
    protected void doProcess(ProcessContext processContext) throws Throwable {
        Object object = processContext.proceed();
        String cacheKey = processContext.getCacheKey();
        DoubleCache doubleCache = processContext.getDoubleCache();
        localCacheService.setCache(cacheKey, object, doubleCache.firstCacheTimeout());
        remoteCacheService.setCache(cacheKey, object, doubleCache.secondCacheTimeout());
        processContext.setValue(object);
    }

    @Override
    protected String name() {
        return CacheType.PUT.getCode();
    }
}
